import javax.swing.*;
import javax.swing.undo.*;
import java.awt.event.*;
import java.io.*;

final class UndoItem extends AbstractAction{
  private final Doer frame;
  UndoItem(String name,Doer frame){
    super(name);
    this.frame=frame;
    putValue(SHORT_DESCRIPTION,name);
    String iconFileName="images"+File.separator+name+".gif";
    if(new File(iconFileName).exists())putValue(SMALL_ICON,new ImageIcon(iconFileName));
  }
  public void actionPerformed(ActionEvent e){
    undoFile();
  }
  public void undoFile(){
    InterWindow interWindow=(InterWindow)(frame.getTab().getComponentAt(frame.getSelect()));
    if(interWindow.getDo()!=null){
      try{
        interWindow.getDo().undo();
      }
      catch(CannotUndoException e){}
    }
  }
}
